package com.ad.pet.common.data.utils.ui;

import android.app.Activity;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

import com.ad.pet.common.structure.AppManager;
import com.ad.pet.common.structure.MainThreadHandler;


/**
 * Created by z on.
 * Des:踢下线工具类
 * Date: 2017/4/26
 */

public class KickUtil {


    private static AlertDialog sAlertDialog;

    public static void tip() {
        tip("你的账号已在别处登录");
    }

    public static void tip(final String msg) {
        final Activity activity = AppManager.getAppManager()
                .firstActivity();
        MainThreadHandler.post(new Runnable() {
            @Override
            public void run() {
                if (sAlertDialog != null && sAlertDialog.isShowing()) {
                    return;
                }
                if (sAlertDialog == null) {
                    sAlertDialog = DialogUtil.createDialog(activity,
                            "异常",
                            msg,
                            false,
                            "退出",
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
//                                    Navigation.logout(activity, true);
                                }
                            }, "重新登录", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
//                                    Navigation.logout(activity, false);
                                }
                            });
                } else {
                    sAlertDialog.show();
                }
            }
        });


    }


}
